let jwt = require("jsonwebtoken");

module.exports = {

    // 生成签名|令牌
    sigin: ({
        username,
        _id
    }) => {
        if (!username || !_id) return;
        return jwt.sign({
            username,
            _id
        }, "user", {
            expiresIn: 60 * 60 * 24
        });
    },
    // 校验签名

    verift: token => new Promise((reslove, reject) => {
        jwt.verify(token, "user", (err, decode) => !err ? reslove(decode) : reject(err.message))
    })
}